[py] Add type hints to remote webdriver and related modules#17002
[py] Add type hints to remote webdriver and related modules#17002mzyndul wants to merge 5 commits intoSeleniumHQ:trunkfrom
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
…yndul/selenium into py-add-type-hints-to-remote-webdriver
User description
🔗 Related Issues
💥 What does this PR do?
Adds type annotations to the remote WebDriver module and related files to improve static type checking and IDE support.
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
Add comprehensive type hints to remote WebDriver module
Improve static type checking and IDE support across related modules
Use cast() for execute() return values with known types
Add TypeVar pattern for decorator function signature preservation
Convert ScriptKey._id to always be str for consistent typing
File Walkthrough
webdriver.py
Add comprehensive type hints to WebDriver classpy/selenium/webdriver/remote/webdriver.py
WebDriver class
(title, current_url, page_source, etc.)
get_window_size, add_cookie, pin_script
optional dict access chains
dict[str, int] and dict[str, Any] returns
bidi_connection async generator
script_key.py
Add type hints and improve ScriptKey hashabilitypy/selenium/webdriver/remote/script_key.py
virtual_authenticator.py
Add type hints to virtual authenticator decoratorspy/selenium/webdriver/common/virtual_authenticator.py
required_virtual_authenticator decorators